package activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import com.example.studyAndroid.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * note:
 * User: Shaxj
 * Date: 15-5-25
 * Time: 上午10:45
 */
public class SimpleAdapterActivity extends Activity implements View.OnClickListener {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.simpleadapter);
        init();
    }

    public void init() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("view1", "hello android1-1");
        map1.put("view2", "hello android1-2");
        Map<String, Object> map2 = new HashMap<String, Object>();
        map2.put("view1", "hello android2-1");
        list.add(map1);
        list.add(map2);
        String from[] = {"view1", "view2"};
        int to[] = {R.id.textView1, R.id.textView2};

        android.widget.SimpleAdapter simpleAdapter = new android.widget.SimpleAdapter(this, list, R.layout.simpleadapter, from, to);
        ListView view = (ListView) findViewById(R.id.listViewAdapter);
        view.setAdapter(simpleAdapter);


        Button bu = (Button) findViewById(R.id.tabTestButton);
        bu.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.tabTestButton) {
            Intent intent = new Intent(this, TestTabActivity.class);
            startActivity(intent);
        }
    }
}